
/**
 * Filters for packets with a particular type of packet extension.
 *
 * @author Matt Tucker
 */
class PacketExtensionFilter : public PacketFilter {
public:
    /**
     * Creates a new packet extension filter. Packets will pass the filter if
     * they have a packet extension that matches the specified element name
     * and namespace.
     *
     * @param elementName the XML element name of the packet extension.
     * @param namespace the XML namespace of the packet extension.
     */
    PacketExtensionFilter(std::string & elementName, std::string & nameSpace) :
		elementName(elementName), 
		nameSpace(nameSpace)
	{}

    /**
     * Creates a new packet extension filter. Packets will pass the filter if they have a packet
     * extension that matches the specified namespace.
     *
     * @param namespace the XML namespace of the packet extension.
     */
    PacketExtensionFilter(std::string & nameSpace) :
		elementName(""),
		nameSpace(nameSpace)
	{}

    bool accept(Packet * packet) {
        return packet->getExtension(elementName, nameSpace) != NULL;
    }

private:
	std::string elementName;
	std::string nameSpace;
}
